package com.dhh.web.modules.menu.domain;

import com.dhh.web.modules.user.domain.Perms;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
import java.util.Set;

/**
 * @Auther: dhh
 * @Date: 2018/11/20 10:48
 * @Email: fzlinjianhui@163.com
 * @Description:
 */
@Table(name = "dhh_web_menu")
@Getter
@Setter
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Menu implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final Integer MENU = 1;
    public static final Integer BUTTON = 2;

    @Id
    @Column(length = 32)
    private String menuId;

    @Column(length = 32)
    private String pid;

    @OneToMany
    @JoinColumn(name = "pid")
    private List<Menu> children;

    @Column(length = 10)
    @NotBlank(message = "菜单名不能为空")
    private String name;

    private String url;

    /**
     * 需要有这些权限才拥有这个菜单
     */
    @OneToMany
    @JsonIgnore
    private Set<Perms> perms;
    /**
     * 类型     0：目录   1：菜单   2：按钮
     */
    private Integer type;
    /**
     * 菜单图标
     */
    @Column(length = 20)
    private String icon;

    /**
     * 排序
     */
    private Integer orderNum;
}
